package com.library.slayer.service.persistence;

import java.util.List;

import com.library.slayer.model.LMSBook;
import com.library.slayer.model.impl.LMSBookImpl;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
import com.liferay.util.dao.orm.CustomSQLUtil;

public class LMSBookFinderImpl extends BasePersistenceImpl implements LMSBookFinder{
	public static String FIND_BOOKS = LMSBookFinderImpl.class.getName()
			+ ".findBooks";

	public List<LMSBook> findBooks(String bookTitle) throws SystemException {
		Session session = openSession();
		String sql = CustomSQLUtil.get(FIND_BOOKS);
		SQLQuery query = session.createSQLQuery(sql);
		query.addEntity("LMSBook", LMSBookImpl.class);
		QueryPos qPos = QueryPos.getInstance(query);
		qPos.add(bookTitle);
		return (List<LMSBook>) query.list();
	}

}
